package com.koron.common.core.business.common.mapper;

import com.koron.bean.base.Attachment;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author jkw
 */
public interface AttachmentMapper {

    /**
     * 批量新增
     *
     * @param list
     * @return 返回影响的行数
     */
    int batchInsert(List<Attachment> list);

    /**
     * 新增
     *
     * @param attachment
     */
    void insert(Attachment attachment);

    /**
     * 修改
     *
     * @param attachment
     */
    int update(Attachment attachment);

    /**
     * 根据业务id删除
     *
     * @param businessId
     * @return 返回影响的行数
     */
    int deleteByBusinessId(@Param("businessId") String businessId);

    /**
     * 根据业务id查询附件列表
     *
     * @param businessId
     * @return 附件列表
     */
    List<Attachment> listByBusinessId(@Param("businessId") String businessId, @Param("subBusinessId") String subBusinessId, @Param("businessType") String businessType);

    /**
     * 根据附件id获取附件
     *
     * @param id 附件id
     * @return 附件
     */
    Attachment getById(@Param("id") String id);

    /**
     * 根据附件id数组，获取附件列表
     *
     * @param ids 附件id
     * @return 附件列表
     */
    List<Attachment> getListByIds(@Param("array") String[] ids);

    /**
     * 批量删除附件
     *
     * @param ids 附件id
     * @return 影响的行数
     */
    int batchDelete(@Param("array") String[] ids);

    /**
     * 根据附件url
     *
     * @param attachmentUrl 附件url
     * @return 附件实体
     */
    Attachment getByUrl(String attachmentUrl);

    List<Attachment> listByBusinessIds(@Param("array") String[] businessIds, @Param("businessType") String businessType);
}
